//
//  HWNavgationView.m
//  嗨文
//
//  Created by 响当当 on 5/17/19.
//  Copyright © 2019 dongzheng. All rights reserved.
//

#import "HWNavgationView.h"

@implementation HWNavgationView
- (UIImageView *)line
{
    if (!_line) {
        _line = [[UIImageView alloc] initWithFrame:CGRectMake(0, NAVIBAR_HEIGHT-0.5-10, SCREEN_WIDTH, 0.5)];
        _line.backgroundColor = [UIColor grayColor];
    }
    return _line;
}

- (UIButton *)backBtn
{
    if (!_backBtn)
    {
        _backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_backBtn setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
        [_backBtn setImage:[UIImage imageNamed:@"back"] forState:UIControlStateHighlighted];
        [_backBtn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
        _backBtn.frame = CGRectMake(5,IS_INCH_X ? 30 : 10, 44, 44);
        _backBtn.imageEdgeInsets = UIEdgeInsetsMake(10,10,10,10);
    }
    return _backBtn;
}

- (UIImageView *)topTitleView
{
    if (!_topTitleView) {
        _topTitleView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, NAVIBAR_HEIGHT-10*kUIScaleBasePlus)];
        _topTitleView.backgroundColor = JSAMainColor;
        _topTitleView.userInteractionEnabled = YES;
        [self addSubview:_topTitleView];
    }
    return _topTitleView;
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        [self addSubview:self.topTitleView];
        [self.topTitleView addSubview:self.backBtn];
        [self.topTitleView addSubview:self.line];
    }
    return self;
}

- (void)backAction
{
    if (self.getBackBlock)
    {
        self.getBackBlock();
    }
}
@end
